from plugin import plugin

__doc__ = "links"

class hi(plugin):
	"Prints titles when links are posted"
	
	def __init__(self):
		self._version = '3.0 stable'
		self.tlds = ['aero', 'asia', 'biz', 'cat', 'com', 'co.uk', 'coop', 'edu', 'gov', 'info', 'int', 'jobs', 'mil', 'mobi', 'museum', 'name', 'net', 'org', 'pro', 'tel', 'travel']
		self.headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}
	
	def _inTLD(self, word):
		for tld in self.tlds:
			if '.' + tld in word:
				return word
		

	def _onMessage(self, msg):
		data = msg['data'].split()
		links = map(self._inTLD, data)
		for link in links:
			if link:
				try: pass
				except: pass
